<%= form_for [:admin, @order], :validate => true do |f| %>

  <%= render "shared/error_messages", :target => @order %>

  <table class="with_border">
    <tbody>
      <tr>
        <th>Objednáno:</th>
        <td><%= raw(l @order.completed_at, :format => :long) %></td>
      </tr>
      <tr>
        <th>Číslo objednávky:</th>
        <td><%= @order.number %></td>
      </tr>
      <tr>
        <th>Celková cena zboží:</th>
        <td><%= number_to_currency(@order.item_total) %></td>
      </tr>
      <tr>
        <th>Způsob přepravy:</th>
        <td><%= @order.shipment.shipping_method.name rescue 'Nebyl nalezen.' %> ()</td>
      </tr>
      <tr>
        <th>Způsob platby</th>
        <td><%= @order.payment.billing_method.name rescue 'Nebyl nalezen.' %> ()</td>
      </tr>
      <tr>
        <th>Celková cena objednávky</th>
        <th><%= number_to_currency(@order.total) %></th>
      </tr>
      <tr>
        <th>Stav objednávky</th>
        <td>
          <% unless @order.deleted? %>
            <%= f.select :state, {"#{t 'enumerations.order.state.completed'}" => "new", "#{t 'enumerations.order.state.canceled'}" => "canceled", "#{t 'enumerations.order.state.shipped'}" => "shipped", "#{t 'enumerations.order.state.returned'}" => "returned", "#{t 'enumerations.order.state.resumed'}" => "resumed", "#{t 'enumerations.order.state.deleted'}" => "deleted"}, {}, {:style => "width: 170px;"} %>
          <% else %>
            <%= f.submit "Obnovit objednávku", :name => "restore" %>
          <% end %>
        </td>
      </tr>
      <tr>
        <th>Potvrzení objednávky</th>
        <td><%= @order.email_confirmation.blank? ? raw("Nebyla potvrzena #{f.submit "Odeslat potvrzení", :name => "confirm"}") : "Byla potvrzena (#{raw(l @order.email_confirmation, :format => :long)})" %></td>
      </tr>
      <% unless @order.user_note.blank? %>
      <tr>
        <th>Zpráva od zákazníka</th>
        <td><%= f.text_area :user_note, :style => "width: 600px; height: 70px;" %></td>
      </tr>
      <% end %>
    </tbody>
  </table>

  <p>Pdf verze objednávky &raquo;<%# link_to "Pdf verze objednávky", admin_order_path(@order, :format => :pdf) %></p>

  <%= render "comments", :f => f %>

  <% unless @order.order_items.blank? %>
    <h3>Položky objednávky</h3>

    <%= render "order_items", :f => f %>
  <% end %>

  <h3>Zákazník</h3>

  <%= render "user_info", :f => f %>
<% end %>